﻿/*
*VMukti -- An open source video conferencing platform.
*
* Copyright (C) 2007 - 2008, VMukti Solutions Pvt. Ltd.
*
* Hardik Sanghvi <hardik@vmukti.com>
*
* See http://www.vmukti.com for more information about
* the VMukti project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, forums and mailing lists
* for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using VMuktiAPI;

namespace VMukti.Presentation.Controls
{
    public partial class CtlExpanderItem : System.Windows.Controls.UserControl, IDisposable
    {
        string strImgPath = "";

        public string Caption
        {
            get
            {
                return lblContent.Content.ToString();
            }
            set
            {
                lblContent.Content = value;

            }
        }

        public string Image
        {
            get
            {
                return strImgPath;
            }
            set
            {
                strImgPath = value;
                if (value != "")
                {
                    grdMain.ColumnDefinitions[0].Width = new GridLength(20);
                    imgItem.Visibility = Visibility.Visible;
                    imgItem.Source = new BitmapImage(new Uri(strImgPath, UriKind.RelativeOrAbsolute));
                }
                else
                {
                    imgItem.Source = null;
                    grdMain.ColumnDefinitions[0].Width = new GridLength(0);
                    imgItem.Visibility = Visibility.Collapsed;
                }
            }
        }

        public CtlExpanderItem()
        {
            try
            {
                this.InitializeComponent();
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "CtlExpanderItem()--:--CtlExpanderItem.xaml.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);

            }
        }

        public void GotFocus()
        {
            try
            {
                lblContent.Foreground = Brushes.White;
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "GotFocus()--:--CtlExpanderItem.xaml.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);

            }
        }

        public void LostFocus()
        {
            try
            {
                lblContent.Foreground = Brushes.Black;
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "LostFocus()--:--CtlExpanderItem.xaml.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);

            }
        }

        ~CtlExpanderItem()
        {
            Dispose();
        }


        #region IDisposable Members

        public void Dispose()
        {
            if (strImgPath != null)
            {
                strImgPath = null;
            }
            
        }

        #endregion
    }
}